<?php  
include 'codeBack.config.php';
include "connectMysql.php";
include "empty.php";
include 'header.php';
$date = $_POST['date'];
$morning = $_POST['morning'];
$afternoon = $_POST["afternoon"];
$evening = $_POST["evening"];
$other = $_POST["other"];
$user_id = $_POST["user_id"];
$token = $_POST["token"];
$id = (int)$_POST["id"];
if(!$date || !$morning || !$afternoon || !$evening || !$other || !$user_id || !$id || !$token){
	exit();
}

$ac_user_sql = "SELECT * FROM ac_user WHERE user_id='{$user_id}' AND token='{$token}'";
$ac_user_result = $mysqli->query($ac_user_sql);
$ac_user_row = mysqli_fetch_object($ac_user_result);
if($ac_user_row->token == $token && $ac_user_row->user_id == $user_id){
	// 查找成功
	$ac_user_info_sql = "UPDATE ac_user_info SET date='{$date}',morning='{$morning}',afternoon='{$afternoon}',evening='{$evening}',other='{$other}' WHERE id='{$id}' AND user_id='{$user_id}'" ;
	$ac_user_info_result = $mysqli->query($ac_user_info_sql);
	if($ac_user_info_result){
		$data = [
			"code"=>$CodeBack["EDITSUBMIT_SUCCESS_CODE"],
			"user_id"=>$user_id,
			"id"=>$id,
			"message"=>"修改成功",
		];
		echo json_encode($data);
	}else {
		$data = [
			"code"=>$CodeBack["EDITSUBMIT_FAILED_CODE"],
			"user_id"=>$user_id,
			"id"=>$id,
			"message"=>"修改失败",
		];
		echo json_encode($data);
	}
	
}
